/**
  ETFAna project, Anyang Normal University && IMP-CAS
  \class ETFDC
  \brief for DCs downstream the dipole magnet
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-10-28
  \date 2021-12-09 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-10-28   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021-2024 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFDC_h
#define ETFDC_h

#include "ETFVDC.h"

class TClonesArray;

class ETFDC : public ETFVDC{
public:
  ETFDC(){}
  ETFDC(const char *name);
  virtual ~ETFDC();

  virtual void Initialize() override; ///< initialize the detector
  virtual void DrawHits() override; ///< draw the hits
  /// set the wire's projection to its normal plane
  virtual void SetHitProjection(ETFDCHit *h, DCType typeDC) override;
  virtual void Register() override; ///< register hits to the main output tree
  virtual void PostAssign() override; ///< finish the processing of all the assigned data

  /// get the fired sense wire layer
  /// \param type: XUV or XY, DC type; x12: X1 or X2
  virtual TClonesArray *GetHitsArray(DCType typeDC, int x12) override;
  virtual void Print() override; ///< print the detector info

  /// r = r(t); drift distance - drift time relation
  virtual double SpaceTimeRelation(double t) override;
  void SetPhiAvrg(double p){ fPhiAvrg = p; }

  // ClassDef(ETFDC, 0);

protected:
  /// \param wireId: 0-159, along x increasing direction
  /// \param type: 0-1-2: X-U-V or X-Y--
  virtual void AddHit(const ETFRawChannel *ch, int wireId, DCType typeDC) override;
  /// \param chId0: starting channel id for an ordered numbered set of wires
  virtual void FillChIdMap(int chId0) override; ///< fill the (channel id <-> uid) map
  using ETFVDC::Filter;
  virtual void Filter() override; ///< filter all layers

  /// the six layers of fired sense wires
  TClonesArray *fHits[3][2]; //! ///< [xuv][x1-x2]
  double fPhiAvrg; //! ///< the average phi of DC0-1-2, used to calculate wire projections
};

#endif
